package com.cssw.fyzb.busi.api.live;

import com.cssw.fyzb.busi.service.live.AnchorService;
import com.cssw.fyzb.busi.service.live.LiveService;
import com.cssw.fyzb.core.model.dodb.CmfAnchorBlacklist;
import com.cssw.fyzb.core.model.dodb.CmfLiveKickOut;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 踢人
 * @author wondream
 */
@Function(description = "踢人", parameters = {
        @Parameter(name = "liveId", type = Type.String, description = "直播ID", required = true),
        @Parameter(name = "koUserId", type = Type.String, description = "被踢出用户", required = true),
        @Parameter(name = "userId", type = Type.String, description = "用户ID", required = true)
})
@Component
public class AddLiveKickOut implements Action {

    @Autowired
    LiveService liveService;

    @Override
    public Response execute(Request request) throws Exception {
        Long liveId = request.getLong("liveId");
        Long koUserId = request.getLong("koUserId");
        Long userId = request.getLong("userId");
        CmfLiveKickOut cmfLiveKickOut = liveService.queryLiveKickOut(liveId, userId, koUserId);
        if(cmfLiveKickOut != null){
            return Response.fail("请勿重复操作");
        }
        liveService.addLiveKickOut(liveId, userId, koUserId);

        //todo 踢人的实际动作

        return Response.success("操作成功");
    }
}
